<?php
//=======================================
//###################################
// Kayako Web Solutions
//
// Source Copyright 2001-2004 Kayako Infotech Ltd.
// Unauthorized reproduction is not allowed
// License Number: $%LICENSE%$
// $Author: vshoor $ ($Date: 2007/02/21 11:18:26 $)
// $RCSfile: upgrade.php,v $ : $Revision: 1.5 $ 
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
//###################################
//=======================================


if (!defined("INSWIFT")) {
	trigger_error("Unable to process $PHP_SELF", E_USER_ERROR);
}

// Core Module
$_SWIFT["query"]["alter"]["customfields"][] = "ALTER TABLE `". TABLE_PREFIX ."customfields` ADD description VARCHAR(255) NOT NULL DEFAULT '';";

if (in_array(MODULE_LIVESUPPORT, $registeredmodules))
{
	$_SWIFT["query"]["alter"]["chatobjects"][] = "ALTER TABLE `". TABLE_PREFIX ."chatobjects` ADD INDEX chatobjects9 (chatstatus, staffid, dateline);";
}

if (in_array(MODULE_TICKETS, $registeredmodules))
{
	require_once ("./modules/tickets/tickets.php");
	require_once ("./modules/tickets/functions_tickets.php");
	$_SWIFT["query"]["alter"]["ticketstatus"][] = "ALTER TABLE `". TABLE_PREFIX ."ticketstatus` ADD (type ENUM('public', 'private') NOT NULL DEFAULT 'public', resetduetime SMALLINT(1) UNSIGNED NOT NULL DEFAULT '0');";

	$_SWIFT["query"]["update"]["ticketstatus"][] = "UPDATE `". TABLE_PREFIX ."ticketstatus` SET `type` = 'public';";
}

execAllQueries();

if (in_array(MODULE_TICKETS, $registeredmodules))
{
	// ======= STATUS CACHE =======
	rebuildStatusCache();
}

upgrade_updateVersion("3.04.50");

?>